 {block name="body"}
<link rel="shortcut icon" href="favicon.ico">
<link href="__CSS__/bootstrap.min.css" rel="stylesheet">
<link href="__CSS__/font-awesome.min.css" rel="stylesheet">
<link href="__CSS__/animate.min.css" rel="stylesheet">
<link href="__CSS__/style.min.css" rel="stylesheet">
<link href="__CSS__/admin.css" rel="stylesheet">
<div class="ibox float-e-margins">
	<div class="ibox-content">
		<div class="form-group" style="padding-left: 20px;">
				单号 <input type="text" id="sn" name="sn" value="{$sn}" class="bank" />
				{if $type==1}
				入库类型 <select  id="stocktype" name="stocktype" class="bank" >
		                <option value="1">采购入库</option>
		                <option value="2">其他入库</option>
		            </select>
		        {elseif $type==2}
		        	出库类型 <select  id="stocktype" name="stocktype" class="bank" >
		                <option value="3">销售出库</option>
		                <option value="4">其他出库</option>
		            </select>
		        {/if}
				日期 <input type="text" id="add_time" name="add_time" value="{$add_time}" class="bank" />
				制单人<input type="text" id="czy" name="czy" value="{$czy}" class="bank" />
			</div>		
		<div class="hr-line-dashed"></div>
		<table class="table table-bordered table-hover">
			<thead>
				<tr class="long-th">
					<th>商品名称</th>
					{if $type==1}
					<th>入库数量</th>
					{elseif $type==2}
					<th>出库数量</th>
					{/if}
					<th>备注</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td class="text-center"><input type="text" id="goods_name" disabled="" value="{$name}" class="form-control" style="text-align: center;"/></td>
					<td class="text-center"><input type="text" id="stock" value="" class="form-control" style="text-align: center;"/></td>
					<td class="text-center"><textarea id="comment" name="comment" rows="2" style="width: 150px;"></textarea></td>
				</tr>
			</tbody>
		</table>
		<div class="form-group">
			<label class="col-sm-2 control-label">备注：</label>
			<div class="input-group col-sm-4">
				<textarea id="comments" name="comments" rows="3" style="width: 300px;" placeholder="备注"></textarea>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label">经办人：</label>
			<div class="input-group col-sm-4">
				<input type="text" id="jbrname" name="jbrname"  value="" placeholder="经办人" class="form-control" />
			</div>
		</div>
		<div class="form-group">
			<div class="col-sm-4 col-sm-offset-8" style="text-align: right;">	
				<input type="hidden" name="goods_id" id="goods_id" value="{$id}" />
				<input type="hidden" name="type" id="type" value="{$type}" />
				<button class="btn btn-info"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;
				<span onclick="wclose()"><a class="btn btn-danger"><i class="fa fa-arrow-left"></i> 返回 </a></span>
			</div>
		</div>
	</div>
</div>
{/block} {block name="script"}
<script src="__JS__/jquery.min.js"></script>
<script src="__JS__/bootstrap.min.js"></script>
<script src="__JS__/jquery.metisMenu.js"></script>
<script src="__JS__/jquery.slimscroll.min.js"></script>
<script src="__LIB__/layer/layer.js"></script>
<script src="__JS__/core.min.js"></script>
<script src="__JS__/pace.min.js"></script>
<script src="__JS__/jquery.form.js"></script>
<script src="__LIB__/datepicker/WdatePicker.js"></script>
<script src="__LIB__/validate/jquery.validate.min.js"></script>
<script src="__LIB__/validate/messages_zh.min.js"></script>
<script src="__LIB__/validate/add_validate.min.js"></script>
<script src="__LIB__/fileinput/js/fileinput.min.js"></script>
<script src="__LIB__/fileinput/js/locales/zh.js"></script>
<script src="__LIB__/ueditor/ueditor.config.js" type="text/javascript"></script>
<script src="__LIB__/ueditor/ueditor.all.js" type="text/javascript"></script>
<script>
	function wclose(){
    	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
        parent.layer.close(index);  
	}
</script>
<script>
	$("#check").click(function(){
        if(this.checked){
            $("input[name='ids[]']").each(function(){this.checked=true})
        }else{
            $("input[name='ids[]']").each(function(){this.checked=false})
        }
    });
    
    $(".btn-info").click(function(){
    	var type = '{$type}';
    	var stocknum = '{$stock}';
    	var stock = $("#stock").val();
    	if(type==1){	    	
	    	if(!stock){
	    		layer.msg("入库库存不能为空,且只能为1-1000000的整数");
	    		return;
	    	}	
    	}else if(type==2){
	    	if(!stock){
	    		layer.msg("出库库存不能为空,且只能为1-1000000的整数");
	    		return;
	    	}	
	    	if(parseInt(stock)>parseInt(stocknum)){
	    		layer.msg("库存不足");
	    		return;
	    	}	    	
    	}
		
    	$.ajax({
	            type:"POST",
	            url:"savecrkc",
				data:{sn:$("#sn").val(),stock:$("#stock").val(),add_time:$("#add_time").val(),
				goods_id:$("#goods_id").val(),goods_name:$("#goods_name").val(),comment:$("#comment").val(),czy:$("#czy").val(),type:type,
				stocktype:$("#stocktype").val(),comments:$("#comments").val(),jbrname:$("#jbrname").val()},
				async:false,
	            success:function(dt){
					layer.msg(dt.msg, {
					  icon: 1,
					  time: 1000 //2秒关闭（如果不配置，默认是3秒）
					}, function(){
						if(dt.code == 200) {
							parent.layer.closeAll();
       						parent.window.location.reload();
       					}
					}); 
	            }
		});		
    });
</script>
<style>
.bank{
	width: 150px;
    height:30px;
    text-align:center;
    border-radius:5px;
}
</style>
{/block}